package com.yoshino.leetcode.oneHundred.sixteenth;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Solution {
    public String minNumber(int[] nums) {
        List<String> lists = new ArrayList<>();
        for (int num : nums) {
            lists.add(String.valueOf(num));
        }
        lists.sort((l1, l2) -> (l1 + l2).compareTo(l2 + l1));
        StringBuilder sb = new StringBuilder();
        lists.forEach(sb::append);
        return sb.toString();
    }

        public boolean isStraight(int[] nums) {
            Arrays.sort(nums);
            int count = 0;
            for (int num : nums) {
                if (num == 0) {
                    count++;
                }
            }
            if (count > 3) {
                return true;
            }
            int first = nums[count];
            for (int i = count + 1; i < nums.length; ) {
                first++;
                if (first == nums[i]) {
                    i++;
                } else {
                    if (--count < 0) {
                        return false;
                    }
                }
            }
            return true;
        }
}